/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Pendataan;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author basisb12da
 */
public class pendataanTableModel extends AbstractTableModel {

    private List<Pendataan> Data1 = new ArrayList<Pendataan>();

    public pendataanTableModel(List<Pendataan> pinjam) {
        this.Data1 = pinjam;
    }

    public void deleteArea(int row) {
        Data1.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void updateArea(int row, Pendataan kat) {
        Data1.set(row, kat);
        fireTableRowsDeleted(row, row);

    }

    public int getRowCount() {
        return Data1.size();
    }

    public int getColumnCount() {
        return 4;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Pendataan b = Data1.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return b.getJudulBuku();
            case 1:
                return b.getPenerbit();
            case 2:
                return b.getNoBuku();
            case 3:
                return b.getKuota();
            default:
                return "";
        }

    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "judul buku";
            case 1:
                return "penerbit";
            case 2:
                return "noBuku";
            case 3:
                return "kuota";
            default:
                return "";
        }
    }
}
